﻿#include "UCircularArcUMG.h"

#include "Blueprint/WidgetLayoutLibrary.h"
#include "ListLibrary/ListUIStyle.h"

UCircularArcUMG::UCircularArcUMG()
	:radius(50)
	,LoopWidth(20)
	,CenterX(90)
	,CenterY(90)
	,BkColor(FLinearColor(0.01,0.05,0.36,1))
	,BeginAngle(120)
	,EndAngle(60)
	,MaXValue(500)
	,DrawValue(200)
	,DrawColor(FLinearColor(0.05,0.52,0.09,1))
,Definition(50)
{

}

TSharedRef<SWidget> UCircularArcUMG::RebuildWidget()
{
	CircularArc = SNew(SCircularArc);
	return CircularArc.ToSharedRef();
}

const FText UCircularArcUMG::GetPaletteCategory()
{
	return FText::FromString(TEXT("小辉辉"));
}

//资源释放
void UCircularArcUMG::ReleaseSlateResources(bool bReleaseChildren)
{
	Super::ReleaseSlateResources(bReleaseChildren);
	
	CircularArc.Reset();
}

void UCircularArcUMG::UpDataList(int Value)
{
	if(Value > MaXValue)
		Value = MaXValue;
	if(Value < 0)
		Value =0;
	DrawValue = Value;
	CircularArc->DrawValue = DrawValue;
}

//更新UI
void UCircularArcUMG::SynchronizeProperties()
{
	Super::SynchronizeProperties();
	
	CircularArc->radius = radius;
	CircularArc->LoopWidth = LoopWidth;
	CircularArc->CenterX = CenterX;
	CircularArc->CenterY = CenterY;
	CircularArc->BkColor = BkColor;
	CircularArc->BeginAngle = BeginAngle;
	CircularArc->EndAngle = EndAngle;
	CircularArc->MaXValue = MaXValue;
	CircularArc->DrawValue = DrawValue;
	CircularArc->DrawColor = DrawColor;
	CircularArc->UseDefaultColor = UseDefaultColor;
	CircularArc->Definition = (100.0 - Definition) / 100.0;
	if(CircularArc->Definition < 0.1)
		CircularArc->Definition = 0.1;
}